package com.yj.web.WeChat.Base;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yanlinyang on 2017/4/18.
 */
public abstract class WxRequest<T extends WxResponse> {
    @Getter
    protected WxHttpMethod mothod = WxHttpMethod.Get;
    @Getter
    protected Map<String, String> parameters;
    protected String baseUrl;
    @Getter
    protected String body;
    protected String path;

    public WxRequest() {
        this(WxBaseUrl.COMMON);
    }

    public WxRequest(String baseUrl) {
        this.baseUrl = baseUrl;
        this.parameters = new HashMap<String, String>();
    }
    public void addParameter(String key, String value) {
        parameters.put(key, value);
    }
    public String getUrl() {
        return baseUrl + path;
    }
    public abstract T createResponse(String body) throws WxException;
}
